<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>


<script>
  let arr = [23, 'aa', function () {
    alert('hi')
  }, '100', 99]

  /*
  * forEach()
  * map()
  * find()
  * findIndex()
  * filter()
  * every()
  * some()
  * */
  // 拷贝数组，拷贝对象
  // 合并数组 [...[], ...[]]，合并对象 {...{}, ...{}}
  // 类数组 -> 数组


  /*
  let res = arr.forEach((item, index) => {
    console.log(index, item)
    return 123
  })
  console.log(res)
  console.log('================')
  let res1 = arr.map((item, index) => {
    console.log(index, item)
    // return index
    return typeof(item)
  })
  console.log(res1)*/
  /*
  // 返回值是查找到的对应项
  let res = arr.find((item, index) => {
    // console.log(index, item)
    // return typeof(item) === 'function'
    return typeof(item) === 'number'
  })
  console.log(res)
  // 返回值是查找到的对应项的index
  console.log(arr.findIndex(item => item === 99))
  */
  //
  // 过滤 以数组形势 返回所有符合条件的项
  // console.log(arr.filter(item => typeof(item) === 'number'))
  // console.log(arr.filter(item => typeof(item) !== 'function'))

  // 返回 boolean, 每一项符合条件
  // console.log([1, 2, 45, 99, 34].every(item => item > 0))
  // 返回 boolean, 某一项符合条件
  // console.log([1, 2, 45, 99, 34].some(item => item > 100))


  /*
  console.log([1, 2, 45, 99, 34].reduce((prev, current, index) => {
    // console.log('current', current)
    return prev + current
  }))*/






</script>
</body>
</html>